<?php
	date_default_timezone_set('Asia/Shanghai');
	
	class gameService {
		
		function submitInfo($workid,$name,$gender,$age,$country) {
			require 'config.php';
			$sql = "insert into user(Worker_ID,Name,Gender,Age,Country) values ('$workid','$name','$gender','$age','$country')";
			if (mysql_query($sql)){
				return "done";
			}else{
				return "error";
			}
			mysql_close();
		}

		function checkUser($workid) {
			require 'config.php';
			$sql = "select * from user where Worker_ID=$workid";
			$query = mysql_query($sql);
			$rows=mysql_fetch_array($query);
			if ($rows['Worker_ID']==$workid) {
			   return "done";
			}else{
				return "error";
			}
			mysql_close();
		}

		function guess($workid,$answer,$number) {
			require 'config.php';
			$sql = "insert into guess(Worker_ID,Answer,Dots_Number) values ('$workid','$answer','$number')";
			if (mysql_query($sql)){
				return "error";
			}else{
				return "done";
			}
			mysql_close();
		}

		function above_below($workid,$answer,$number) {
			require 'config.php';
			$sql = "insert into above_below(Worker_ID,Answer,Dots_Number) values ('$workid','$answer','$number')";
			if (mysql_query($sql)){
				return "done";
			}else{
				return "error";
			}
			mysql_close();
		}

		function gambling($workid,$answer,$number) {
			require 'config.php';
			$sql = "insert into gambling(Worker_ID,Answer,Dots_Number) values ('$workid','$answer','$number')";
			if (mysql_query($sql)){
				return "error";
			}else{
				return "done";
			}
			mysql_close();
		}
			
			
	}
?>
